package com.smg.crm.utils;

import java.util.HashMap;
import java.util.Map;

/**
 * 公共的返回值
 *      返回的是map集合
 *          可以将该集合转换为json进行返回
 */
public class HandleFlag {

    /*public static Map<String,Object> handleFlag(boolean flag){

        Map<String,Object> map = new HashMap<>();
        map.put("success",flag);
        return map;

    }*/

    //转换json
    //Map -> { "success" : true }
    public static Map<String,Object> successTrue(){

        Map<String,Object> map = new HashMap<>();
        map.put("success",true);
        return map;

    }

    //Map -> { "success" : true , "key" : xxx/{...}/[{...}...]}
    public static Map<String,Object> successObj(String key,Object obj){

        Map<String,Object> map = new HashMap<>();
        map.put("success",true);
        map.put(key,obj);
        return map;

    }

    //转换json
    //Map -> { "success" : false , "msg":xxx }
    public static Map<String,Object> error(String msg){

        Map<String,Object> map = new HashMap<>();
        map.put("success",false);
        map.put("msg",msg);
        return map;

    }


}
